package com.mlnx.work.pojo.vo;

import com.mlnx.work.enums.ProjectStatusEnum;
import com.mlnx.work.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("子任务列表返回参数类")
public class ChildTaskListVO {

    @ApiModelProperty("任务ID")
    private Integer taskId;

    @ApiModelProperty("任务名称")
    private String taskName;

    @ApiModelProperty("最初计划开始时间")
    private Long originStartTime;

    @ApiModelProperty("最初计划截止时间")
    private Long originEndTime;

    @ApiModelProperty("负责人")
    private String manager;

    @ApiModelProperty("风险项")
    private String risk;

    @ApiModelProperty("任务状态")
    private ProjectStatusEnum status;

    public String getStatus() {
        if (ProjectStatusEnum.ING.equals(status))
            if (DateUtil.dateCompare(originEndTime, System.currentTimeMillis()) < 0)
                status = ProjectStatusEnum.OVERDUE;
            else if (!risk.trim().isEmpty())
                status = ProjectStatusEnum.RISK;

        return status.getStatus();
    }
}
